# 处理数据计算用程序
import numpy as np
from time import sleep
from pathlib2 import Path
# 模拟一个predict
class Predictor:
    def __init__(self, file_path=None):        
        if file_path is not None:
            self.file_path = Path(file_path)
            self.file_list = list(self.file_path.glob('*.png'))
        else:
            # 生成一个随机数组 
            self.file_list = np.arange(42)

    def predict(self):
        for index,value in enumerate(self.file_list):
            sleep(1)
            re = int(index+1 / len(self.file_list) *100)
            yield re

# 模拟数据处理
class Calculator:
    def __init__(self, file_path=None):
        self.file_path = file_path
        if self.file_path is not None:
            self.file_list = self.file_path.glob('*.png')
            sleep(1)
        else:
            # 生成正太分布
            self.data_heng = np.random.normal(size=500)
            # 生成均匀分布
            self.data_zong = np.random.uniform(size=500)
        


    def calculate(self):
        sleep(10)
        self.A3_heng = self.data_heng.mean()
        self.A5_heng = self.data_heng.std()        
        self.f10_heng = np.percentile(self.data_heng, 25)
        self.f15_heng = np.percentile(self.data_heng, 50)
        self.f20_heng = np.percentile(self.data_heng, 75)

        self.A3_zong = self.data_zong.mean()
        self.A5_zong = self.data_zong.std()
        self.f10_zong = np.percentile(self.data_zong, 25)
        self.f15_zong = np.percentile(self.data_zong, 50)
        self.f20_zong = np.percentile(self.data_zong, 75)
